#!/bin/bash
#J.Zh.Wu Edit version 0.1
if [ $# -ne 4 ] ; then
echo "usage:---------------------------------"
echo "./cmd_Human.sh fasta_name id_name nstruct p_trials"
echo "for example: ./cmd_Human.sh T0003.fasta T0003 20 2.0"
echo "---------------------------------------"
echo 
echo "exit!"
exit 1
fi

WorkHome="/public/home/users/qiang/FragHome/WorkHome"
PATH_ALL="/public/home/users/qiang/rosetta3"
PATH_ALL_TEST="$PATH_ALL/human"
#PATH_FASTA="$PATH_ALL/fasta"
cd $PATH_ALL_TEST
mkdir $2
DIR_PATH="$PATH_ALL_TEST/$2"
cd $DIR_PATH
mkdir frag


#copy frag and fasta
cp  $WorkHome/$2/$2_fragspecial/aa"$2"03_05.200_v1_3 $DIR_PATH/frag
cp  $WorkHome/$2/$2_fragspecial/aa"$2"09_05.200_v1_3 $DIR_PATH/frag

cp  $WorkHome/$2/$2.fasta $DIR_PATH/



#prepare
cd $DIR_PATH
mkdir pdb
cd $DIR_PATH/pdb

#create backbone flags
echo "-database $PATH_ALL/rosetta3_database">bb_flags
echo "-in:file:frag9 $DIR_PATH/frag/aa"$2"09_05.200_v1_3">>bb_flags
echo "-in:file:frag3 $DIR_PATH/frag/aa"$2"03_05.200_v1_3">>bb_flags
echo "-in:file:fasta $DIR_PATH/$2.fasta">>bb_flags
echo "-out:nstruct $3">>bb_flags
echo "-out:file:silent "$2".silent">>bb_flags
echo "-opt_trials1 $4">>bb_flags
echo "-out:pdb">>bb_flags
#end

#create backbone pbs file
echo "#PBS -N bb.out">bb.pbs
echo "#PBS -l nodes=1:ppn=16">>bb.pbs
echo "#PBS -j oe">>bb.pbs
echo "#PBS -l walltime=1000:00:00">>bb.pbs
echo "cd $DIR_PATH/pdb">>bb.pbs
echo "$PATH_ALL/rosetta3_source/bin/aco2.linuxgccrelease @bb_flags">>bb.pbs
#end

#submit pbs
sleep 20
qsub bb.pbs
